var groupid=window.location.href.split("=")[1];
Ext.setup({
    tabletStartupScreen: 'tablet_startup.png',
    phoneStartupScreen: 'phone_startup.png',
    icon: 'icon.png',
    glossOnIcon: false,
    onReady : function() {
        Ext.regModel('Contact', {
            fields: ['id',
                     'fullname',
                     'age',
                     'groupid',
                     'email']
        });

        var groupingBase = {
            itemTpl: '<div class="contact2"><strong>{fullname}</strong></div>',
            grouped: true,
            indexBar: false,

            onItemDisclosure: {
                scope: 'test',
                handler: function(record, btn, index) {
                	window.location.href = '../companyusers/addcompanyUser.jsp?groupid='+groupid;
                }
            },

            store: new Ext.data.Store({
                model: 'Contact',
                sorters: 'BILLCODE',
                autoLoad: true,
                getGroupString : function(record) {
                    return record.get('fullname')[0];
                },
                proxy:{
                    type:'ajax',
                    url:'../companyuser/companyUseraction.action?groupid='+groupid,
                    reader:{
                        type:'json',
                        root:'namelist'
                    },
                },
            })
        };

        var App = new Ext.Application({
            name: 'NotesApp',
            useLoadMask: true,
            launch: function () {

                NotesApp.views.notesListToolbar1 = new Ext.Toolbar({
                    id: 'notesListToolbar1',
                    items: [
							{
							    xtype:'toolbar',
							    docked:'top',
							
							    items:[
							        {
							            xtype:'searchfield',
							            placeHolder:'Search...',
							            itemId:'searchBox'
							        }
							    ]
							}
                    ]
                });
                
                NotesApp.views.notesListToolbar = new Ext.Toolbar({
                    id: 'notesListToolbar',
                    title: '公司人员通信录',
                    items: [
                            { 
                            	ui:'back', 
                            	text:'返回',
                            	handler:function () {
                                    window.location.href = '../companycomminutes/companyCommunicationsList.jsp';
                                }
                            },
                            {xtype: 'spacer'}, 
                            {
                            	ui:'add', 
                            	text:'增加',
                                handler:function () {
                                    window.location.href = '../companyusers/addcompanyUser.jsp?groupid='+groupid;
                                }
                            },                         
                    ]
                });
                
                NotesApp.views.notesList =  new Ext.List(Ext.apply(groupingBase, {
                    fullscreen: true
                }));
                
                NotesApp.views.notesListContainer = new Ext.Panel({
                    id: 'notesListContainer',
                    layout: 'fit',
                    dockedItems: [NotesApp.views.notesListToolbar,NotesApp.views.notesListToolbar1,NotesApp.views.notesList]
                });

                NotesApp.views.viewport = new Ext.Panel({
                    fullscreen: true,
                    layout: 'card',
                    cardAnimation: 'slide',
                    items: [NotesApp.views.notesListContainer]
                });
            }
        });
        
    }
});
